package LeetCode.month04.day92;

import java.util.HashSet;
import java.util.Set;

/**
 * @author 16778
 * @date 2025/11/1 8:07
 * @description
 */
public class No3217 {

    public ListNode modifiedList(int[] nums, ListNode head) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            set.add(num);
        }
        ListNode res = new ListNode();
        ListNode curr = res;
        while(head!=null){
            if(!set.contains(head.val)){
                curr.next = new ListNode(head.val);
                curr = curr.next;
            }
            head = head.next;
        }
        return res.next;
    }

}

